﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// 上传附件页
/// 创建者：马先光
/// 创建日期：2006-9-7
/// </summary>
public partial class Editor_include_rar : System.Web.UI.Page
{
    public string strFileName;
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Expires = 0;
        Response.Cache.SetNoStore();
        Response.AppendHeader("Pragma", "no-cache"); 
    }

    protected void btnUpLoad_Click(object sender, EventArgs e)
    {
        if (File1.PostedFile.FileName != string.Empty)
        {
            System.Random myRd = new Random();
            string strType = System.IO.Path.GetExtension(File1.PostedFile.FileName).ToLower();
            if (strType == ".rar")
            {
                if (File1.PostedFile.ContentLength > 102400000)
                    Jscript.Alert("上传文件请不要超过10M");
                else
                {
                    string strMiaoShu = d_miaoshu.Value;
                    strFileName = DateTime.Now.ToString().Replace("-", "").Replace(":", "").Replace(" ", "") + myRd.Next(1000) + strType;
                    string strFilePath = Server.MapPath("~/upfile/") + strFileName;
                    File1.PostedFile.SaveAs(strFilePath);
                    strFileName = "upfile/" + strFileName;
                    string js = @"<script language=javascript>";
                    js += " window.returnValue =  '<a href= \"" + strFileName + "\" />" + strMiaoShu + "</a>';";
                    js += "window.close();";
                    js += "</script>";
                    Response.Write(js);
                }
            }
            else
                Jscript.Alert("您选择的文件类型不匹配!");
        }
        else
            Jscript.Alert("请选择要上传的文件!");
    }
}
